nanopyx.core.utils.toot

 1def toot(msg):
 2    """Post a toot to Mastodon
 3    :param msg: The message to post
 4    """
 5    try:
 6        from mastodon import Mastodon
 7    except ImportError:
 8        print("Mastodon is not installed. Skipping toot.")
 9        return
10
11    import requests
12
13    r = requests.get('https://ipinfo.io')
14    data = r.json()
15    msg = f"[{data['city']}:{data['country']}]: {msg}"
16
17    #   Set up Mastodon
18    mastodon = Mastodon(
19        access_token = 'qdFtF6ODx-z4w9O-GIu5iYUyddieCZeAUWXgyQ2scpE',
20        api_base_url = 'https://botsin.space/'
21    )
22
23    mastodon.status_post(msg)
def toot(msg):
 2def toot(msg):
 3    """Post a toot to Mastodon
 4    :param msg: The message to post
 5    """
 6    try:
 7        from mastodon import Mastodon
 8    except ImportError:
 9        print("Mastodon is not installed. Skipping toot.")
10        return
11
12    import requests
13
14    r = requests.get('https://ipinfo.io')
15    data = r.json()
16    msg = f"[{data['city']}:{data['country']}]: {msg}"
17
18    #   Set up Mastodon
19    mastodon = Mastodon(
20        access_token = 'qdFtF6ODx-z4w9O-GIu5iYUyddieCZeAUWXgyQ2scpE',
21        api_base_url = 'https://botsin.space/'
22    )
23
24    mastodon.status_post(msg)

Post a toot to Mastodon

Parameters
  • msg: The message to post